package inherit;

/**
 * Created with IntelliJ IDEA
 * Description:学习继承
 * User:22954
 * Date:2024-01-07
 * Time:20:54
 */
class Base{
    int a;
    int b;
}
class Derived extends Base{
    int a;
    int c;
    public void method(){
        super.a=11;//可用super.访问父类变量
        a=1;       //子类变量和父类变量同名时，优先访问子类变量
        b=2;
        c=3;
        System.out.println(a);
        System.out.println(super.a);
        System.out.println(b);
        System.out.println(c);
    }
}
public class Test2 {
    public static void main(String[] args) {
        Derived derived=new Derived();
        derived.method();
    }
}
